<!-- JX属性值管理 -->
<template>
    <div class="page-box">
        <div class="page-title">
            {{ '属性值管理' }}
        </div>

        <div class="page-search">
            <div class="search-box" :style="{ height: IsHeight }">
                <el-input v-model="pageData.keywords" placeholder="请输入耗材名称" style="width: 200px; margin-right: 10px"
                    suffix-icon="search" />
            </div>
            <div class="search-btn">
                <div class="btn_item" @click="handleClickHeight">
                    <img class="btn_img" src="@/assets/sx.png" alt="" />
                    <span> 高级筛选 </span>
                </div>
            </div>
        </div>
        <div class="search-btn-right">
            <el-button color="#626aef" type="primary" @click="handleClickAdd"> 添加属性值 </el-button>
        </div>
    </div>

    <div class="table-box">
        <el-table :data="tabeData" style="width: 100%" v-loading="loading" border>
            <el-table-column align="center" prop="rowNumber" label="序号" width="auto" /> 
            <el-table-column align="center" prop="title" label="属性名称" width="auto" />
            <el-table-column align="center" prop="title" label="属性值" width="auto" />
            <el-table-column align="center" prop="title" label="创建人" width="auto" />
            <el-table-column align="center" prop="title" label="创建时间" width="auto" />
            <el-table-column fixed="right" label="操作" min-width="150" prop="id" align="center">
                <template #default="scope">
                    <div class="btn-box">
                        <el-button plain size="small" type="primary" @click="handleClick(scope.row)"> 删除产品 </el-button>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
    <!-- 分页 -->
    <Pagination class="pagination" @pageSize="pageSize" @getPage="getPage" :page="pageData.page"
        :page-size="pageData.pageSize" :total="total" />

    <AttributeValuesAdd ref="AttributeValuesAddRef" @init="getAlltabeData" />
</template>

<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useRouter } from "vue-router";
import { usePlatformManagementStore } from "@/stores";
import Pagination from "@/components/Pagination.vue";
import AttributeValuesAdd from "./components/attributeValueManagement/attributeValuesAdd.vue";
const platformManagementStore = usePlatformManagementStore();
const router = useRouter();
import api from "@/api";
//  新增出库
const AttributeValuesAddRef = ref<any>(null);
// 出库详情
let IsHeight = ref<number | string>(0);
// 定义ts数据
interface PageData {
    pageSize: number;
    page: number;
    keywords: string;
}
// 定义数据
const PageData = ref<PageData>({
    pageSize: 10,
    page: 1,
    keywords: "",
});
//  出库详情
const DetailsOutboundOrderVisible = ref<boolean>(false);
// 定义仓库数据类型
interface Warehouse {
    id: string | number;
    title: string;
    code: string;
    house_type?: string;
    house_type_name?: string;
    category_name?: string;
    manager?: string;
    phone?: string;
    address?: string;
    remark?: string;
    parent_id?: string | number;
    parent_name?: string;
    children?: Warehouse[];
    create_time?: string; 
    creator?: string;
    rowNumber?: number;
}
// 出库订单详情
let dialogRow = ref<Warehouse>({} as Warehouse);
//  -----------------列表数据
const pageData = ref({
    pageSize: 10,
    page: 1,
    house_type: "",
    category: "",
    keywords: "",
});
const total = ref(0);
const tabeData = ref([]);
// 侦听动态分页
watch(
    () => {
        return pageData.value;
    },
    () => {
        getAlltabeData();
    },
    { deep: true }
);

let nub = ref<number>(0);
const handleClickHeight = () => {
    nub.value++;
    if (nub.value % 2 == 1) {
        IsHeight.value = '50px';
    } else {
        IsHeight.value = '0px';
    }
}

const pageSize = (e: number) => {

    pageData.value.pageSize = e
}
const getPage = (e: number) => {
    pageData.value.page = e
}
onMounted(() => {
    getAlltabeData();
})

// 获取门店列表
const getAlltabeData = async () => {
    const res = await api.parking.getAll({
        ...pageData.value,
    });
    if (res.code == 0) {
        tabeData.value = res.data.data;

        total.value = res.data.total;
    }
};

const loading = ref(false);
//  打开损耗设置弹窗
const handleClickAdd = () => {
    AttributeValuesAddRef.value.handleDialog();
}
</script>

<style lang="scss" scoped>
.btn-box {
    display: flex;
    align-items: center;
    justify-content: center;
}

// 输入框样式
::v-deep .el-input__wrapper {
    background-color: rgba(250, 252, 251, 1);
}

//表格样式

::v-deep .el-table {
    --el-table-header-bg-color: rgba(235, 236, 240, 1);
}

::v-deep .el-table thead {
    color: #444;
}

//分页样式
.pagination {
    width: calc(100% - 250px);
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding-top: 10px;
    border-top: 1px solid #98989848;


}

::v-deep .el-pagination.is-background .el-pager li.is-active {
    background-color: #000 !important;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 0;
    color: #333;
    background-color: #f5f7fa;
    margin-top: 20px;
}
</style>
